package com.project.server.controller;

import com.poetry.common.entity.common.R;
import com.poetry.common.util.CommonUtil;
import com.project.server.feign.IFileFeign;
import com.project.server.feign.IRedisFeign;
import com.project.server.service.ITestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Objects;

@RestController
@RequestMapping("test")
public class TestController {

    @Value("${path.a}")
    private Integer a;

    @Resource
    private IFileFeign fileFeign;

    @Resource
    private IRedisFeign redisFeign;

    @Resource
    private ITestService testService;

    @GetMapping("test")
    private R<String> test(){
        //名字是空，抛异常
        CommonUtil.checkThrow(Objects::isNull, "张三", "名字是空");
        //集合size大于100，抛异常

        //邮箱不合法，抛异常
        return this.testService.test();
    }

    @GetMapping("set")
    public void set(){
        this.redisFeign.set("demo", "demo");
    }

}
